package com.itheima.cases;

import java.util.Scanner;

public class TextDemo3 {
    public static void main(String[] args) {
        System.out.println("请输入评委个数：");
        Scanner rs = new Scanner(System.in);
        int insert = rs.nextInt();
        if (insert <= 2) {
            System.out.println("评委数量必须大于2。");
        } else {
            System.out.println("最终评分是：" + String.format("%.2f", scorecout(insert)));
        }
    }

    public static double scorecout(int Number) {
        Scanner rs = new Scanner(System.in);
        double[] arr = new double[Number];
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第" + (i + 1) + "个评委的评分：");
            arr[i] = rs.nextDouble();
        }
        double max = arr[0];
        double min = arr[0];
        double sum = 0;
        for (int i = 0; i < arr.length; i++) {
            max = max < arr[i] ? arr[i] : min;
            min = min > arr[i] ? arr[i] : min;
            sum += arr[i];
        }//最大值最小值求和
        double score = ((sum - max - min) / (arr.length - 2));
        return score;
    }
}
